{% extends 'userena/base_userena.html' %}
{% load timeline_widget_tags %}
{% load i18n %}

{% block title %}
  {{ profile.user.username }}的帐号
{% endblock %}

{% block content_title %}
  <h1>
    {{ profile.user.username }}的帐号
  </h2>
{% endblock %}

{% block content %}
  <div class="content">

    {% comment %}Dirty hack. Will use django-guardian in the future.{% endcomment %}
    {% if user.username == profile.user.username %}
      <ul id="profile-nav" class="nav nav-tabs">
        <li class="active"><a href="{% url userena_profile_detail user.username %}">{% trans "View profile" %}</a></li>
        <li><a href="{% url userena_profile_edit user.username %}">{% trans "Edit details" %}</a></li>
        <li><a href="{% url userena_password_change user.username %}">{% trans "Change password" %}</a></li>
        <li><a href="{% url userena_email_change user.username %}">{% trans "Change email" %}</a></li>
      </ul>
    {% endif %}

    <div id="u_details">
      <div class="mugshot">
        <img src="{{ profile.get_mugshot_url }}" alt="{% trans "Your mugshot" %}" />
        {% if user.is_authenticated and user.username != profile.user.username %}
          <a href="{% url userena_umessages_compose_to profile.user.username %}" class="btn" style="margin: 6px 8px">发私信</a>
        {% endif %}
      </div>
      <div class="info">
        <p><strong>加入时间</strong> {{ profile.user.date_joined|date:"Y-m-d H:i" }} </p>
        <p><strong>最近登录</strong> {{ profile.user.last_login|date:"Y-m-d H:i" }} </p>
        <p><strong>{% trans "Website" %}</strong> <a href="{{ profile.website }}">{{ profile.website }}</a></p>
        <p><strong>{% trans "Location" %}</strong> {{ profile.location }}</p>
        <p><strong>{% trans "About me" %}</strong><br />{{ profile.about_me|md }}</p>
      </div>
    </div>

    <hr />

    <div class="timelines" id="id_tls">
      <h2>{{profile}} 创建的时间线</h2>
      {% load pagination_tags %}
      {% autopaginate timelines %}
      {% if timelines %}
        {% for o in timelines %}
          <div class="timeline">
            <div class="pic">
              <img src="{{ o.get_cover_url }}"/>
            </div>
            <div class="info">
              <h3>
                <a href="{% url timeline_detail o.pk %}">{{o.title}}</a>
                {% if o.status == "draft" %} (草稿) {% endif %}
              </h3>
              <div class="extinfo">
                <span>事件: {{o.num_events}}</span>
                <span>浏览: {{o.num_views}}</span>
                <span>回复: {{o.num_replies}}</span>
                <span>by: 
                  <a href="{% url userena_profile_detail o.created_by.username %}">
                    {{o.created_by}}
                  </a>
                </span>
                <span>创建: {{ o.created_on|date:"Y-m-d H:i"}}</span>
              </div>
              {{ o.intro|slice:"160"|linebreaksbr }}{% if o.intro|length > 340 %}...{% endif %} 
            </div>
          </div>
        {% endfor %}
        {% paginate %}
      {% else %}
        还没有创建任何的时间线
      {% endif %}
      
    </div>

  </div>
{% endblock %}
